﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Services;
using Hachi.Controllers;

public partial class usercontrols_Webkit : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    [WebMethod]
    public static string PostProductComment(int pProductID, string pComment, int Vote)
    {
        MembershipUser u = Membership.GetUser();
        if (u != null)
        {
            ProductsController pctr = new ProductsController();
            return pctr.PostProductComment(pProductID, u.UserName, pComment, Vote);
        }
        else
            return "PleaseLogin";
    }

    [WebMethod]
    public static string SubmitServey(int AnswerID, string NameServey, string OrtherAnswer)
    {
        ServeyController sctr = new ServeyController();
        MembershipUser u = Membership.GetUser();
        string user = "visitor";
        if (u != null)
            user = u.UserName;
        if (sctr.AddServey(AnswerID, user, NameServey, OrtherAnswer))
            return "OK";
        else
            return "Fail";
    }

    [WebMethod]
    public static string CheckAvailbleUserName(string UserName)
    {
        if (Membership.GetUser(UserName.Trim()) == null)
            return "OK";
        else
            return "InUse";
    }

    [WebMethod]
    public static string CheckAvailbleEmail(string Email)
    {
        if (string.IsNullOrEmpty(Membership.GetUserNameByEmail(Email.Trim())))
            return "OK";
        else
            return "InUse";
        ;
    }

}